package com.example.springboot.mapper;

import com.example.springboot.entity.vo.CorrectNumVo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CorrectNumMapper {

    @Select("SELECT correct_num FROM correct_num WHERE post_id = #{postId} AND text_id = #{textId}")
    Integer getCorrectNum(@Param("postId") Integer postId, @Param("textId") String textId);

    @Update("UPDATE correct_num SET correct_num = correct_num + 1 WHERE post_id = #{postId} AND text_id = #{textId}")
    void incrementCorrectNum(@Param("postId") Integer postId, @Param("textId") String textId);
    @Insert("insert into correct_num (post_id,text_id,correct_num)values (#{postId},#{textId},1)")
    void insertCorrectNum(Integer postId, String textId);
    @Select("SELECT text_id as textId, correct_num as correctNum FROM correct_num WHERE post_id = #{postId}")
    List<CorrectNumVo> getCorrectNum2(Integer postId);
}
